package hankz.spring.beans.factory.config;

import hankz.spring.beans.PropertyValues;
import lombok.Data;

/**
 * 用于定义 Bean 实例化信息，现在的实现是以一个 Object 存放对象
 *
 * @auther zzc
 * @date 2021 11 15
 */
@Data
public class BeanDefinition {

    String SCOPE_SINGLETON = ConfigurableBeanFactory.SCOPE_SINGLETON;

    String SCOPE_PROTOTYPE = ConfigurableBeanFactory.SCOPE_PROTOTYPE;

    private Class beanClass;

    private PropertyValues propertyValues;

    //初始化
    private String initMethodName;

    //销毁
    private String destroyMethodName;

    //用于把从 spring.xml 中解析到的 Bean 对象作用范围填充到属性中
    private String scope = SCOPE_SINGLETON;

    private boolean singleton = true;

    private boolean prototype = true;


    public BeanDefinition(Class beanClass) {
        this.beanClass = beanClass;
        this.propertyValues = new PropertyValues();
    }

    public BeanDefinition(Class beanClass, PropertyValues propertyValues) {
        this.beanClass = beanClass;
        this.propertyValues = propertyValues != null ? propertyValues : new PropertyValues();
    }
}
